<?php
	require(__META_CONTROLS_GEN__ . '/SampleTitlesMetaControlGen.class.php');

	/**
	 * This is a MetaControl customizable subclass, providing a QForm or QPanel access to event handlers
	 * and QControls to perform the Create, Edit, and Delete functionality of the
	 * SampleTitles class.  This code-generated class extends from
	 * the generated MetaControl class, which contains all the basic elements to help a QPanel or QForm
	 * display an HTML form that can manipulate a single SampleTitles object.
	 *
	 * To take advantage of some (or all) of these control objects, you
	 * must create a new QForm or QPanel which instantiates a SampleTitlesMetaControl
	 * class.
	 *
	 * This file is intended to be modified.  Subsequent code regenerations will NOT modify
	 * or overwrite this file.
	 * 
	 * @package My QCubed Application
	 * @subpackage MetaControls
	 */
	class SampleTitlesMetaControl extends SampleTitlesMetaControlGen {
		// Initialize fields with default values from database definition
/*		
		public function __construct($objParentObject, SampleTitles $objSampleTitles) {
			parent::__construct($objParentObject,$objSampleTitles);
			if ( !$this->blnEditMode ){
				$this->objSampleTitles->Initialize();
			}
		}
*/
                 private $txtaISBN;
                 private $txtaTitle;
                 private $dttTime;
                 private $SampleId;

                 public function txtaISBN_Create($strControlId = null) {
			$this->txtaISBN = new QAjaxAutoCompleteTextBox($this->objParentObject, 'txtaISBN_Change',$strControlId);
                        $this->txtaISBN->Name = QApplication::Translate('ISBN');
                        $this->txtaISBN->MustMatch=true;
                        //if($this->objSample->CompetitorId) $this->txtaISBN->Text = $this->objComCompetitor->CompetitorId->__toString();
			//$this->txtaISBN->MaxLength = SampleTitles:: NameMaxLength;
			return $this->txtaISBN;
		}
                public function txtaTitle_Create($strControlId = null) {
			$this->txtaTitle = new QAjaxAutoCompleteTextBox($this->objParentObject, 'txtaTitle_Change',$strControlId);
                        $this->txtaTitle->Name = QApplication::Translate('Title');
                        $this->txtaTitle->MustMatch=true;
                        //if($this->objSample->CompetitorId) $this->txtaTitle->Text = $this->objComCompetitor->CompetitorId->__toString();
			//$this->txtaTitle->MaxLength = SampleTitles:: NameMaxLength;
			return $this->txtaTitle;
               }
               
               	public function SaveSampleTitles() {
			try {
				// Update any fields for controls that have been created
				$this->objSampleTitles->SampleId = $_SESSION['SampleId'];
                                $tId = Title::LoadByIsbn($this->txtaISBN->Text);
				$this->objSampleTitles->TitleId = $tId->Id;
				if ($this->txtNotes) $this->objSampleTitles->Notes = $this->txtNotes->Text;
				

				// Update any UniqueReverseReferences (if any) for controls that have been created for it

				// Save the SampleTitles object
				$this->objSampleTitles->Save();

				// Finally, update any ManyToManyReferences (if any)
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}
        }
?>